import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/hj_model/video_model.dart';
import 'package:tiktokadult/tools_base/widget/net_image_widget.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';

import '../../../community_business/community_tag_page/community_tag_page.dart';

class TopicItem extends StatelessWidget {
  final TagsBean model;
  final bool isSelect;
  final Function()? onTap;

  const TopicItem({super.key, required this.model, this.onTap, this.isSelect = false});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        if (onTap != null) {
          onTap!();
        } else {
          Get.toNamed(CommunityTagDetailPage.routeName, arguments: model);
        }
      },
      child: Container(
        height: 80,
        padding: EdgeInsets.only(top: 14.h, left: 14.w, right: 14.w, bottom: 14.h),
        decoration: BoxDecoration(
          // border: isSelect ? Border.all(width: 1, color: Color(0xff3476FF)) : null,
          color: Color(0x0DFFFFFF),
          borderRadius: BorderRadius.circular(10),
        ),
        child: Row(
          children: [
            NetworkImageLoader(
              imageUrl: model.coverImg ?? '',
              width: 46,
              height: 46,
              borderRadius: 23,
            ),
            10.sizeBoxW,
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    '#${model.name}',
                    style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                  4.sizeBoxH,
                  Text(
                    '${model.vidCount.humanizeFormat}个帖子  ${model.playCount.humanizeFormat}浏览  ${model.followCount.humanizeFormat}关注',
                    style: TextStyle(color: Color(0x73FFFFFF), fontSize: 12),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                ],
              ),
            ),
            12.sizeBoxW,
            Container(
              width: 52,
              height: 26,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: isSelect ? Color(0xffE1351F) : Color(0x33FFFFFF),
                borderRadius: BorderRadius.circular(30),
              ),
              child: Text(
                isSelect ? '已选' : "选择",
                style: TextStyle(
                  color: isSelect ? Color(0xffffffff) : Color(0xffDCDCDC),
                  fontSize: 14,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
